package com.blast.manager.ui

import android.view.KeyEvent
import com.blast.manager.R
import com.wxl.common.base.AbsActivity
import com.wxl.common.room.entity.LogEntity
import kotlinx.android.synthetic.main.activity_error_help_layout.*

class ErrorHelpActivity : AbsActivity() {

    override fun getCreateContentViewId(): Int {
        return R.layout.activity_error_help_layout
    }

    override fun onCreateViewChanged() {

        setTopTitle("帮助")

        helpErrorText.text = "问题描述：雷管使能开关打开异常。\n问题原因：因前面环节中有标志位未正确置位。\n解决办法：重新走起爆流程。"

        helpErrorBack.setOnClickListener {
            addLog("返回","")
            finish()
        }

        if (intent.hasExtra("type")) {
           val mType = intent.getStringExtra("type")
            if (mType == "5") {
                helpErrorText.setText("问题描述：雷管储能电容电压偏低。\\n问题原因：操作过程中，雷管与母线断开或接触不良。\\n解决办法：重新连接好对应雷管的母线，然后重新检测。")
            } else if (mType == "6") {
                helpErrorText.setText("问题描述：雷管对码异常。\\n问题原因：因静电等原因导致密码丢失。\\n解决办法：重新更换雷管。")
            } else if (mType == "7") {
                helpErrorText.setText("问题描述：雷管使能开关打开异常。\\n问题原因：因前面环节中有标志位未正确置位。\\n解决办法：重新走起爆流程。")
            }
        }
    }

    override fun onKeyDownEvent(keyCode: Int, event: KeyEvent?): Boolean {
        if(keyCode == KeyEvent.KEYCODE_F1 || keyCode == KeyEvent.KEYCODE_BACK){
            helpErrorBack.performClick()
        }
        return true
    }

    private fun addLog(action:String,remark:String){
        LogEntity.addLog(action,"","问题帮助页",0,0.0,0.0,"",0,0,"",remark)
    }
}